package com.eonmind.ai.converts;

import com.eonmind.ai.dto.AiVideoDto;
import com.eonmind.common.contract.enums.ai.AiVideoStatusEnum;
import com.eonmind.common.provider.entity.ai.AiVideo;
import org.springframework.beans.BeanUtils;

import java.util.List;

public class AiVideoConvert {
    public static List<AiVideoDto.VideoTaskQueryResponse> toAiVideoTaskQueryResponseList(List<AiVideo> contentData) {
        List<AiVideoDto.VideoTaskQueryResponse> list = contentData.stream()
                .map(AiVideoConvert::toAiVideoTaskQueryResponse)
                .toList();
        return list;
    }

    private static AiVideoDto.VideoTaskQueryResponse toAiVideoTaskQueryResponse(AiVideo aiVideo) {
        AiVideoDto.VideoTaskQueryResponse aiVideoTaskQueryResponse = new AiVideoDto.VideoTaskQueryResponse();
        BeanUtils.copyProperties(aiVideo, aiVideoTaskQueryResponse);
        Integer status = aiVideoTaskQueryResponse.getStatus();
        AiVideoStatusEnum aiVideoStatusEnum = AiVideoStatusEnum.getByCode(status);
        if (aiVideoStatusEnum != null) {
            aiVideoTaskQueryResponse.setStatusDesc(aiVideoStatusEnum.getDesc());
        }
        return aiVideoTaskQueryResponse;
    }
}
